package com.zr.serviceImpl;

import com.zr.dao.StudentDaoHyx;
import com.zr.daoImpl.StudentDaoImplHyx;
import com.zr.model.Student;
import com.zr.service.StudentServiceHyx;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class StudentServiceImplHyx implements StudentServiceHyx{

	StudentDaoHyx sdao = new StudentDaoImplHyx();
	@Override
	public JSONObject selectStudentByTid(int tid, int page, int size) {
		JSONObject jstu = new JSONObject();
		jstu.put("total", sdao.CountStudentByUid(tid));
		jstu.put("rows", sdao.selStudentByUid(tid, page, size));
		return jstu;
	}

	@Override
	public boolean updateTeacherStudent(int sid, String sname, String sage, String ssex,String saddress, String spnumber,String stime){
		
		return sdao.updateTeacherStudent(sid, sname, sage, ssex, saddress, spnumber,stime);
	}

	@Override
	public JSONObject findAllStudent(int page, int size) {
		JSONObject jstu = new JSONObject();
		jstu.put("total", sdao.CountAllStudent());
		jstu.put("rows", sdao.selectAllStudent(page, size));
		return jstu;
	}

	@Override
	public JSONObject selectStudentByTname(String tname,int tid,int page,int size) {
		JSONObject jstu = new JSONObject();
		jstu.put("total", sdao.CountStudentByTname(tname,tid));
		jstu.put("rows", sdao.selectStudentByTname(tname,tid, page, size));
		return jstu;
	}

	@Override
	public boolean adminUpdateStudent(int sid, String sname, String sage, String ssex, String saddress, String spnumber,
			String stime, String bname) {
		return sdao.adminUpdateStudent(sid, sname, sage, ssex, saddress, spnumber,stime,bname);
	}

	@Override
	public boolean adminAddStudent(String sname, String sage, String ssex, String saddress, String spnumber,
			String stime, String bname) {
		
		return sdao.adminAddStudent(sname, sage, ssex, saddress, spnumber, stime, bname);
	}

	@Override
	public Student findNewStudent(String sname, String sage, String ssex, String saddress, String spnumber,
			String stime, String bname) {

		return sdao.findNewStudent(sname, sage, ssex, saddress, spnumber, stime, bname);
	}

	@Override
	public boolean adminDeleteStudent(int sid) {
		return sdao.adminDeleteStudent(sid);
	}

	@Override
	public boolean adminInsertS_T(int sid, int tid) {
		// TODO Auto-generated method stub
		return sdao.adminInsertS_T(sid, tid);
	}

	@Override
	public JSONArray selectDanStudentByTid(int tid, int sid, String sname) {
		// TODO Auto-generated method stub
		return JSONArray.fromObject(sdao.selectDanStudentByTid(tid, sid, sname));
	}

	@Override
	public int countStudentBySname(int tid, int sid, String sname) {
		// TODO Auto-generated method stub
		return sdao.countStudentBySname(tid, sid, sname);
	}

}
